/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.console.api.business;

import com.farmcode.base.dao.BaseFilter;
import com.farmcode.base.dao.DAOException;
import com.farmcode.base.manager.FacadeException;

import com.farmcode.console.api.model.Match;
import com.farmcode.console.api.dao.MatchDAO;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author oiprado
 */
public class BaseMatchManagerBean implements MatchManager {

    @EJB
    protected MatchDAO matchDAO;

    public BaseMatchManagerBean() {
    }

    @Override
    public void create(Match entity) throws FacadeException {
        try {
            matchDAO.create(entity);
        } catch (DAOException ex) {
            throw new FacadeException(ex);
        }
    }

    @Override
    public void store(Match entity) throws FacadeException {
        try {
            matchDAO.store(entity);
        } catch (DAOException ex) {
            throw new FacadeException(ex);
        }
    }

    @Override
    public void remove(Match entity) throws FacadeException {
        try {
            matchDAO.remove(entity, entity.getId());
        } catch (DAOException ex) {
            throw new FacadeException(ex);
        }
    }

    @Override
    public List<Match> find() throws FacadeException {
        try {
            return matchDAO.find();
        } catch (DAOException ex) {
            throw new FacadeException(ex);
        }
    }

    @Override
    public void setBaseFilter(BaseFilter baseFilter) {
        matchDAO.setFilter(baseFilter);
    }
}
